package cn.danger.com.presenter;

import android.content.Context;

import java.util.Map;

import cn.danger.com.util.FileCacheService;

/**
 * Created by 俊 on 2016/12/30.
 */
public class UserPresenterImpl implements UserPresenter {

    private Context context;

    public UserPresenterImpl(Context context) {
        this.context = context;
    }

    @Override
    public void showFinishedEvent() {
        FileCacheService service = new FileCacheService(context);
        Map<String, Object> map = (Map<String, Object>) service.getSharePreference("setting");
        if ((boolean)map.get("show_finished_event") == true) {
            map.put("show_finished_event", false);
        } else {
            map.put("show_finished_event", true);
        }
        service.saveSharePreference("setting", map);
    }

    @Override
    public void updateWorkColor(int position) {
        FileCacheService service = new FileCacheService(context);
        Map<String, Object> map = (Map<String, Object>) service.getSharePreference("setting");
        map.put("work_color", position);
        service.saveSharePreference("setting", map);
    }

    @Override
    public void updateRouteColor(int position) {
        FileCacheService service = new FileCacheService(context);
        Map<String, Object> map = (Map<String, Object>) service.getSharePreference("setting");
        map.put("route_color", position);
        service.saveSharePreference("setting", map);
    }

    @Override
    public void updateLifeColor(int position) {
        FileCacheService service = new FileCacheService(context);
        Map<String, Object> map = (Map<String, Object>) service.getSharePreference("setting");
        map.put("life_color", position);
        service.saveSharePreference("setting", map);
    }

}
